package com.zc.im.register.loadbanacer;

import org.apache.curator.framework.recipes.cache.ChildData;

import java.util.List;
import java.util.Random;

/**
 * Project：im
 * Date：2022/4/27
 * Time：15:54
 * Description：随机策略
 *
 * @author Challen.Zhang
 * @version 1.0
 */
public class RandomConnectLoadBalancer implements ConnectLoadBalancer {


    @Override
    public String getServer(List<ChildData> list) {

        Random random = new Random();

        return list.get(random.nextInt(list.size())).getPath();
    }

    @Override
    public String getType() {
        return "random";
    }

}
